#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>

#include "core.h"
#include "screen.h"
#include "exception.h"
#include "input.h"


int core::init()
{
  /* init core and add-ons */
  if(SDL_Init(SDL_INIT_VIDEO)==-1) throw exception(std::string("SDL internal error: ")+SDL_GetError());
  SDL_EnableUNICODE(true);

  if(IMG_Init(IMG_INIT_PNG)!=IMG_INIT_PNG) throw exception(std::string("SDL_image error: ")+IMG_GetError());

  if(TTF_Init()==-1) throw exception(std::string("SDL_ttf error: ")+TTF_GetError());

  int ret = screen::init();
  if(ret==0) input::reset();

  return ret;
}

void core::quit()
{
  TTF_Quit();
  IMG_Quit();
  SDL_Quit();
}
